home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / games / nhak_src.zip / MONDATA.C < prev    next >
C/C++ Source or Header  |  1993-03-16  |  17KB  |  768 lines

  1. /*    SCCS Id: @(#)mondata.c    3.0    89/11/21
  2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3. /* NetHack may be freely redistributed.  See license for details. */
  4.  
  5. #include "hack.h"
  6. #include "eshk.h"
  7. #include "epri.h"
  8.  
  9. /*    These routines provide basic data for any type of monster. */
  10.  
  11. #ifdef OVL0
  12.  
  13. boolean
  14. attacktype(ptr, atyp)
  15.     register struct    permonst    *ptr;
  16.     register int atyp;
  17. {
  18.     int    i;
  19.  
  20.     for(i = 0; i < NATTK; i++)
  21.         if(ptr->mattk[i].aatyp == atyp) return(TRUE);
  22.  
  23.     return(FALSE);
  24. }
  25.  
  26. #endif /* OVL0 */
  27. #ifdef OVLB
  28.  
  29. boolean
  30. resists_ston(ptr)    /* returns TRUE if monster is petrify resistant */
  31.     register struct permonst *ptr;
  32. {
  33.     return (ptr->mflags1 & (M1_STON_RES | M1_ACID) || dmgtype(ptr, AD_STON));
  34. }
  35.  
  36. boolean
  37. resists_drli(ptr)    /* returns TRUE if monster is drain-life resistant */
  38.  
  39.     register struct permonst *ptr;
  40. {
  41.     return(is_undead(ptr) || is_demon(ptr) || is_were(ptr));
  42. }
  43.  
  44. #endif /* OVLB */
  45. #ifdef OVL0
  46.  
  47. boolean
  48. ranged_attk(ptr)    /* returns TRUE if monster can attack at range */
  49.     register struct permonst *ptr;
  50. {
  51.     return (attacktype(ptr, AT_BREA) || attacktype(ptr, AT_WEAP) ||
  52.         attacktype(ptr, AT_SPIT) || attacktype(ptr, AT_GAZE) ||
  53.         attacktype(ptr, AT_MAGC));
  54. }
  55.  
  56. #endif /* OVL0 */
  57. #ifdef OVL1
  58.  
  59. boolean
  60. can_track(ptr)        /* returns TRUE if monster can track well */
  61.     register struct permonst *ptr;
  62. {
  63. #ifdef NAMED_ITEMS
  64.     if(uwep && !strcmp(ONAME(uwep), "Excalibur")) return TRUE;
  65. #endif
  66.     return(haseyes(ptr));
  67. }
  68.  
  69. #endif /* OVL1 */
  70. #ifdef OVLB
  71.  
  72. #ifdef POLYSELF
  73. boolean
  74. breakarm(ptr)    /* creature will break out of armor */
  75.     register struct permonst *ptr;
  76. {
  77.     return(bigmonst(ptr) || (ptr->msize > MZ_SMALL && !humanoid(ptr))
  78. #ifdef INFERNO
  79.            || ptr == &mons[PM_MARILITH]
  80. #endif
  81.            );
  82.     /* Marilith is about the only case of a monster which is otherwise
  83.      * humanoid but cannot wear armor (too many arms).  Centaurs would
  84.      * be another except that they are already accounted for by
  85.      * bigmonst.
  86.      */
  87. }
  88.  
  89. boolean
  90. sliparm(ptr)    /* creature will slide out of armor */
  91.     register struct permonst *ptr;
  92. {
  93.     return(ptr->msize < MZ_LARGE &&
  94.            (ptr->msize <= MZ_SMALL || ptr == &mons[PM_GHOST]));
  95. }
  96. #endif
  97.  
  98. #endif /* OVLB */
  99. #ifdef OVL1
  100.  
  101. boolean
  102. sticks(ptr)    /* creature sticks other creatures it hits */
  103.     register struct permonst *ptr;
  104. {
  105.     return(dmgtype(ptr,AD_STCK) || dmgtype(ptr,AD_WRAP) ||
  106.         attacktype(ptr,AT_HUGS));
  107. }
  108.  
  109. /* not one hundred percent correct: now a snake may hide under an
  110.  *                    invisible object.
  111.  */
  112. boolean
  113. canseemon(mtmp)
  114.     register struct monst *mtmp;
  115. {
  116.     return((!mtmp->minvis || See_invisible)
  117.         && (!mtmp->mhide ||
  118.             (!OBJ_AT(mtmp->mx, mtmp->my) &&
  119.              levl[mtmp->mx][mtmp->my].gmask == 0))
  120.         && cansee(mtmp->mx, mtmp->my));
  121. }
  122.  
  123. boolean
  124. dmgtype(ptr, dtyp)
  125.     register struct    permonst    *ptr;
  126.     register int dtyp;
  127. {
  128.     int    i;
  129.  
  130.     for(i = 0; i < NATTK; i++)
  131.         if(ptr->mattk[i].adtyp == dtyp) return TRUE;
  132.  
  133.     return FALSE;
  134. }
  135.  
  136. int
  137. monsndx(ptr)        /* return an index into the mons array */
  138.     struct    permonst    *ptr;
  139. {
  140. #ifdef LATTICE_504_BUG
  141.     register int d;
  142. /* no problem - see, pspace IS bounded (and fits in 32 bits!) KL */
  143. const int pspace= sizeof(struct permonst[NUMMONS])/NUMMONS;
  144. #endif
  145.     register int    i;
  146.  
  147.     if(ptr == &playermon) return(-1);
  148. #ifndef LATTICE_504_BUG
  149.     i = (int)(ptr - &mons[0]);
  150. #else
  151.     d=(int)((int)ptr-(int)&mons[0]);
  152.     i= d/pspace;
  153. #endif
  154.     if(i < 0 || i >= NUMMONS) {    
  155.         panic("monsndx - could not index monster (%x)", ptr);
  156.         return FALSE;        /* will not get here */
  157.     }
  158.  
  159.     return(i);
  160. }
  161.  
  162. int
  163. name_to_mon(str)
  164. char *str;
  165. {
  166.     /* Be careful.  We must check the entire string in case it was
  167.      * something such as "ettin zombie corpse".  The calling routine
  168.      * doesn't know about the "corpse" until the monster name has
  169.      * already been taken off the front, so we have to be able to
  170.      * read the name with extraneous stuff such as "corpse" stuck on
  171.      * the end.
  172.      * This causes a problem for names which prefix other names such
  173.      * as "ettin" on "ettin zombie".  In this case we want the _longest_
  174.      * name which exists.
  175.      * This also permits plurals created by adding suffixes such as 's'
  176.      * or 'es'.  Other plurals must still be handled explicitly.
  177.      */
  178.     register int i;
  179.     register int mntmp = -1;
  180.     register char *s;
  181.     char buf[BUFSZ];
  182.     int len=0;
  183.  
  184.     Strcpy(buf, str);
  185.     str = buf;
  186.     if (!strncmp(str, "a ", 2)) str += 2;
  187.     else if (!strncmp(str, "an ", 3)) str += 3;
  188.  
  189.     /* Some irregular plurals */
  190. #ifdef INFERNO
  191.     if (!strncmp(str, "incubi", 6)) return PM_INCUBUS;
  192.     if (!strncmp(str, "succubi", 7)) return PM_SUCCUBUS;
  193. #endif
  194.     if (!strncmp(str, "violet fungi", 12)) return PM_VIOLET_FUNGUS;
  195.     if (!strncmp(str, "homunculi", 9)) return PM_HOMUNCULUS;
  196.     if (!strncmp(str, "baluchitheria", 13)) return PM_BALUCHITHERIUM;
  197.     if (!strncmp(str, "lurkers above", 13)) return PM_LURKER_ABOVE;
  198.     if (!strncmp(str, "cavemen", 7)) return PM_CAVEMAN;
  199.     if (!strncmp(str, "cavewomen", 9)) return PM_CAVEWOMAN;
  200.     if (!strncmp(str, "zruties", 7)) return PM_ZRUTY;
  201.     if (!strncmp(str, "djinn", 5)) return PM_DJINNI;
  202.     for(s=str; *s; s++) {
  203.         if (!strncmp(s, "vortices", 8)) {
  204.             Strcpy(s+4, "ex");
  205.             break;
  206.         }
  207.         /* be careful with "ies"; "priest", "zombies" */
  208.         if (!strncmp(s, "jellies", 7) || !strncmp(s, "mummies", 7)) {
  209.             Strcpy(s+4, "y");
  210.             break;
  211.         }
  212.         if (!strncmp(s, "ves", 3)) {
  213.         /* luckily no monster names end in fe or ve with ves plurals */
  214.             Strcpy(s, "f");
  215.             break;
  216.         }
  217.     }
  218.     
  219.     for(i = 0; mons[i].mlet; i++) {
  220.         if(!strncmp(mons[i].mname, str, strlen(mons[i].mname))) {
  221.             if (strlen(mons[i].mname) > len) {
  222.                 mntmp = i;
  223.                 len = strlen(mons[i].mname);
  224.             }
  225.         }
  226.     }
  227.     return mntmp;
  228. }
  229.  
  230. #endif /* OVL1 */
  231. #ifdef OVLB
  232.  
  233. #ifdef POLYSELF
  234. boolean
  235. webmaker(ptr)   /* creature can spin a web */
  236.     register struct permonst *ptr;
  237. {
  238.     return (ptr->mlet == S_SPIDER && ptr != &mons[PM_SCORPION]);
  239. }
  240. #endif
  241.  
  242. boolean
  243. is_female(mtmp)
  244.     register struct monst *mtmp;
  245. {
  246.     if (mtmp->isshk) return !ESHK(mtmp)->ismale;
  247. #if defined(ALTARS) && defined(THEOLOGY)
  248.     if (mtmp->ispriest) return !EPRI(mtmp)->ismale;
  249. #endif
  250.     return !!(mtmp->data->mflags2 & M2_FEM);
  251. }
  252.  
  253. #endif /* OVLB */
  254. #ifdef OVL2
  255.  
  256. /* Gender function.  Differs from is_female() in that 1) It allows the monster
  257.  * type of a polymorphed shopkeeper to override ESHK(mtmp)->ismale, and 2)
  258.  * it returns 3 values (0=male, 1=female, 2=none) instead of 2.
  259.  */
  260. int
  261. gender(mtmp)
  262.     register struct monst *mtmp;
  263. {
  264.     if (!humanoid(mtmp->data)) return 2;
  265.     if (mtmp->data->mflags2 & M2_FEM) return 1;
  266.     if (mtmp->data == &mons[PM_CAVEMAN]
  267.         || mtmp->data == &mons[PM_PRIEST]
  268. #ifdef INFERNO
  269.         || mtmp->data == &mons[PM_INCUBUS]
  270. #endif
  271.                         ) return 0;
  272. #if defined(ALTARS) && defined(THEOLOGY)
  273.     if (mtmp->ispriest) return !EPRI(mtmp)->ismale;
  274. #endif
  275.     if (mtmp->isshk) return !ESHK(mtmp)->ismale;
  276.     return 0;
  277. }
  278.  
  279. #endif /* OVL2 */
  280. #ifdef OVLB
  281.  
  282. boolean
  283. levl_follower(mtmp)
  284. register struct monst *mtmp;
  285. {
  286.     return (mtmp->mtame || (mtmp->data->mflags2 & M2_STALK) || is_fshk(mtmp)
  287.         || (mtmp->iswiz && !mon_has_amulet(mtmp)));
  288. }
  289.  
  290. struct permonst *
  291. player_mon()
  292. {
  293.     switch (pl_character[0]) {
  294.         case 'A': return &mons[PM_ARCHEOLOGIST];
  295.         case 'B': return &mons[PM_BARBARIAN];
  296.         case 'C': if (flags.female) return &mons[PM_CAVEWOMAN];
  297.             else return &mons[PM_CAVEMAN];
  298.         case 'E': return &mons[PM_ELF];
  299.         case 'H': return &mons[PM_HEALER];
  300.         case 'K': return &mons[PM_KNIGHT];
  301.         case 'P': if (flags.female) return &mons[PM_PRIESTESS];
  302.             else return &mons[PM_PRIEST];
  303.         case 'R': return &mons[PM_ROGUE];
  304.         case 'S': return &mons[PM_SAMURAI];
  305.         case 'T': return &mons[PM_TOURIST];
  306.         case 'V': return &mons[PM_VALKYRIE];
  307.         case 'W': return &mons[PM_WIZARD];
  308.         default: impossible("what are you?");
  309.             return &mons[PM_HUMAN];
  310.     }
  311. }
  312.  
  313. const int grownups[][2] = { {PM_LITTLE_DOG, PM_DOG}, {PM_DOG, PM_LARGE_DOG},
  314.     {PM_HELL_HOUND_PUP, PM_HELL_HOUND}, {PM_KITTEN, PM_HOUSECAT},
  315.     {PM_HOUSECAT, PM_LARGE_CAT}, {PM_BABY_GRAY_DRAGON, PM_GRAY_DRAGON},
  316.     {PM_KOBOLD, PM_LARGE_KOBOLD}, {PM_LARGE_KOBOLD, PM_KOBOLD_LORD},
  317.     {PM_GNOME, PM_GNOME_LORD}, {PM_GNOME_LORD, PM_GNOME_KING},
  318.     {PM_DWARF, PM_DWARF_LORD}, {PM_DWARF_LORD, PM_DWARF_KING},
  319.     {PM_SMALL_MIMIC, PM_LARGE_MIMIC}, {PM_LARGE_MIMIC, PM_GIANT_MIMIC},
  320.     {PM_BAT, PM_GIANT_BAT},
  321.     {PM_LICH, PM_DEMILICH}, {PM_DEMILICH, PM_MASTER_LICH},
  322.     {PM_OGRE, PM_OGRE_LORD}, {PM_OGRE_LORD, PM_OGRE_KING},
  323.     {PM_VAMPIRE, PM_VAMPIRE_LORD},
  324.     {PM_BABY_RED_DRAGON, PM_RED_DRAGON},
  325.     {PM_BABY_WHITE_DRAGON, PM_WHITE_DRAGON},
  326.     {PM_BABY_BLUE_DRAGON, PM_BLUE_DRAGON},
  327.     {PM_BABY_GREEN_DRAGON, PM_GREEN_DRAGON},
  328.     {PM_BABY_ORANGE_DRAGON, PM_ORANGE_DRAGON},
  329.     {PM_BABY_BLACK_DRAGON, PM_BLACK_DRAGON},
  330.     {PM_BABY_YELLOW_DRAGON, PM_YELLOW_DRAGON},
  331.     {PM_RED_NAGA_HATCHLING, PM_RED_NAGA},
  332.     {PM_BLACK_NAGA_HATCHLING, PM_BLACK_NAGA},
  333.     {PM_GOLDEN_NAGA_HATCHLING, PM_GOLDEN_NAGA},
  334.     {PM_GUARDIAN_NAGA_HATCHLING, PM_GUARDIAN_NAGA},
  335.     {PM_BABY_PURPLE_WORM, PM_PURPLE_WORM},
  336. #ifdef WORM
  337.     {PM_BABY_LONG_WORM, PM_LONG_WORM},
  338. #endif
  339. #ifdef ARMY
  340.     {PM_SOLDIER, PM_SERGEANT},
  341.     {PM_SERGEANT, PM_LIEUTENANT},
  342.     {PM_LIEUTENANT, PM_CAPTAIN},
  343. #endif
  344.     {PM_BABY_CROCODILE, PM_CROCODILE},
  345.     {-1,-1}
  346. };
  347.  
  348. int little_to_big(montype)
  349. int montype;
  350. {
  351. #ifndef AIXPS2_BUG
  352.     register int i;
  353.     
  354.     for(i=0; grownups[i][0] >= 0; i++)
  355.         if(montype == grownups[i][0]) return grownups[i][1];
  356.     return montype;
  357. #else
  358. /* AIX PS/2 C-compiler 1.1.1 optimizer does not like the above for loop,
  359.  * and causes segmentation faults at runtime.  (The problem does not
  360.  * occur if -O is not used.)
  361.  * lehtonen@cs.Helsinki.FI (Tapio Lehtonen) 28031990
  362.  */
  363.     int i;
  364.     int monvalue;
  365.  
  366.     monvalue = montype;
  367.     for(i=0; grownups[i][0] >= 0; i++)
  368.         if(montype == grownups[i][0]) monvalue = grownups[i][1];
  369.     
  370.     return monvalue;
  371. #endif
  372. }
  373.  
  374. int big_to_little(montype)
  375. int montype;
  376. {
  377.     register int i;
  378.     
  379.     for(i=0; grownups[i][0] >= 0; i++)
  380.         if(montype == grownups[i][1]) return grownups[i][0];
  381.     return montype;
  382. }
  383.  
  384.  
  385. const char *
  386. locomotion(ptr, def)
  387. const struct permonst *ptr;
  388. const char *def;
  389. {
  390.     return (
  391.         is_floater(ptr) ? "float" :
  392.         is_flyer(ptr) ? "fly" :
  393.         slithy(ptr) ? "slither" :
  394.         amorphous(ptr) ? "ooze" :
  395.         nolimbs(ptr) ? "crawl" :
  396.         def
  397.            );
  398.  
  399. }
  400.  
  401. #ifdef STUPID_CPP    /* otherwise these functions are macros in mondata.h */
  402.  
  403. int
  404. bigmonst(ptr) struct permonst *ptr; {
  405.     return(ptr->msize >= MZ_LARGE);
  406. }
  407.  
  408. int
  409. verysmall(ptr) struct permonst *ptr; {
  410.     return(ptr->msize < MZ_SMALL);
  411. }
  412.  
  413. int
  414. is_flyer(ptr) struct permonst *ptr; {
  415.     return((ptr->mflags1 & M1_FLY) != 0L);
  416. }
  417.  
  418. int
  419. is_floater(ptr) struct permonst *ptr; {
  420.     return(ptr->mlet == S_EYE);
  421. }
  422.  
  423. int
  424. is_swimmer(ptr) struct permonst *ptr; {
  425.     return((ptr->mflags1 & M1_SWIM) != 0L);
  426. }
  427.  
  428. int
  429. passes_walls(ptr) struct permonst *ptr; {
  430.     return((ptr->mflags1 & M1_WALLWALK) != 0L);
  431. }
  432.  
  433. int
  434. noncorporeal(ptr) struct permonst *ptr; {
  435.     return(ptr->mlet == S_GHOST);
  436. }
  437.  
  438. int
  439. amorphous(ptr) struct permonst *ptr; {
  440.     return((ptr->mflags1 & M1_AMORPHOUS) != 0L);
  441. }
  442.  
  443. int
  444. tunnels(ptr) struct permonst *ptr; {
  445.     return((ptr->mflags1 & M1_TUNNEL) != 0L);
  446. }
  447.  
  448. int
  449. needspick(ptr) struct permonst *ptr; {
  450.     return((ptr->mflags1 & M1_NEEDPICK) != 0L);
  451. }
  452.  
  453. int
  454. hides_under(ptr) struct permonst *ptr; {
  455.     return((ptr->mflags1 & M1_CONCEAL) != 0L);
  456. }
  457.  
  458. int
  459. is_hider(ptr) struct permonst *ptr; {
  460.     return((ptr->mflags1 & M1_HIDE) != 0L);
  461. }
  462.  
  463. int
  464. haseyes(ptr) struct permonst *ptr; {
  465.     return((ptr->mflags1 & M1_NOEYES) == 0L);
  466. }
  467.  
  468. int
  469. nohands(ptr) struct permonst *ptr; {
  470.     return((ptr->mflags1 & M1_NOHANDS) != 0L);
  471. }
  472.  
  473. int
  474. nolimbs(ptr) struct permonst *ptr; {
  475.     return((ptr->mflags1 & M1_NOLIMBS) == M1_NOLIMBS);
  476. }
  477.  
  478. # ifdef POLYSELF
  479. int
  480. polyok(ptr) struct permonst *ptr; {
  481.     return((ptr->mflags1 & M1_NOPOLY) == 0L);
  482. }
  483. # endif
  484.  
  485. int
  486. is_whirly(ptr) struct permonst *ptr; {
  487.     return((ptr->mlet == S_VORTEX) || 
  488.            (ptr == &mons[PM_AIR_ELEMENTAL]));
  489. }
  490.  
  491. int
  492. humanoid(ptr) struct permonst *ptr; {
  493.     return((ptr->mflags1 & M1_HUMANOID) != 0L);
  494. }
  495.  
  496. int
  497. is_animal(ptr) struct permonst *ptr; {
  498.     return((ptr->mflags1 & M1_ANIMAL) != 0L);
  499. }
  500.  
  501. int
  502. slithy(ptr) struct permonst *ptr; {
  503.     return((ptr->mflags1 & M1_SLITHY) != 0L);
  504. }
  505.  
  506. int
  507. thick_skinned(ptr) struct permonst *ptr; {
  508.     return((ptr->mflags1 & M1_THICK_HIDE) != 0L);
  509. }
  510.  
  511. int
  512. resists_fire(ptr) struct permonst *ptr; {
  513.     return((ptr->mflags1 & M1_FIRE_RES) != 0L);
  514. }
  515.  
  516. int
  517. resists_sleep(ptr) struct permonst *ptr; {
  518.     return((ptr->mflags1 & M1_SLEE_RES) != 0L || is_undead(ptr));
  519. }
  520.  
  521. int
  522. resists_cold(ptr) struct permonst *ptr; {
  523.     return((ptr->mflags1 & M1_COLD_RES) != 0L);
  524. }
  525.  
  526. int
  527. resists_disint(ptr) struct permonst *ptr; {
  528.     return(ptr == &mons[PM_BLACK_DRAGON] ||
  529.         ptr == &mons[PM_BABY_BLACK_DRAGON]);
  530. }
  531.  
  532. int
  533. resists_elec(ptr) struct permonst *ptr; {
  534.     return((ptr->mflags1 & M1_ELEC_RES) != 0L);
  535. }
  536.  
  537. int
  538. resists_acid(ptr) struct permonst *ptr; {
  539.     return((ptr->mflags1 & M1_ACID) != 0L);
  540. }
  541.  
  542. int
  543. acidic(ptr) struct permonst *ptr; {
  544.     return((ptr->mflags1 & M1_ACID) != 0L);
  545. }
  546.  
  547. int
  548. resists_poison(ptr) struct permonst *ptr; {
  549.     return((ptr->mflags1 & (M1_POIS | M1_POIS_RES)) != 0L);
  550. }
  551.  
  552. int
  553. poisonous(ptr) struct permonst *ptr; {
  554.     return((ptr->mflags1 & M1_POIS) != 0L);
  555. }
  556.  
  557. int
  558. regenerates(ptr) struct permonst *ptr; {
  559.     return((ptr->mflags1 & M1_REGEN) != 0L);
  560. }
  561.  
  562. int
  563. perceives(ptr) struct permonst *ptr; {
  564.     return((ptr->mflags1 & M1_SEE_INVIS) != 0L);
  565. }
  566.  
  567. int
  568. can_teleport(ptr) struct permonst *ptr; {
  569.     return((ptr->mflags1 & M1_TPORT) != 0L);
  570. }
  571.  
  572. int
  573. control_teleport(ptr) struct permonst *ptr; {
  574.     return((ptr->mflags1 & M1_TPORT_CONTROL) != 0L);
  575. }
  576.  
  577. int
  578. is_armed(ptr) struct permonst *ptr; {
  579.     return(attacktype(ptr, AT_WEAP));
  580. }
  581.  
  582. int
  583. likes_gold(ptr) struct permonst *ptr; {
  584.     return((ptr->mflags1 & M1_GREEDY) != 0L);
  585. }
  586.  
  587. int
  588. likes_gems(ptr) struct permonst *ptr; {
  589.     return((ptr->mflags1 & M1_JEWELS) != 0L);
  590. }
  591.  
  592. int
  593. likes_objs(ptr) struct permonst *ptr; {
  594.     return((ptr->mflags1 & M1_COLLECT) != 0L || is_armed(ptr));
  595. }
  596.  
  597. int
  598. likes_magic(ptr) struct permonst *ptr; {
  599.     return((ptr->mflags1 & M1_MAGIC) != 0L);
  600. }
  601.  
  602. int
  603. is_undead(ptr) struct permonst *ptr; {
  604.     return((ptr->mflags2 & M2_UNDEAD) != 0L);
  605. }
  606.  
  607. int
  608. is_were(ptr) struct permonst *ptr; {
  609.     return((ptr->mflags2 & M2_WERE) != 0L);
  610. }
  611.  
  612. int
  613. is_elf(ptr) struct permonst *ptr; {
  614.     return((ptr->mflags2 & M2_ELF) != 0L);
  615. }
  616.  
  617. int
  618. is_dwarf(ptr) struct permonst *ptr; {
  619.     return((ptr->mflags2 & M2_DWARF) != 0L);
  620. }
  621.  
  622. int
  623. is_giant(ptr) struct permonst *ptr; {
  624.     return((ptr->mflags2 & M2_GIANT) != 0L);
  625. }
  626.  
  627. # ifdef GOLEMS
  628. int
  629. is_golem(ptr) struct permonst *ptr; {
  630.     return(ptr->mlet == S_GOLEM);
  631. }
  632. # endif /* GOLEMS */
  633.  
  634. int
  635. is_domestic(ptr) struct permonst *ptr; {
  636.     return((ptr->mflags2 & M2_DOMESTIC) != 0L);
  637. }
  638.  
  639.  
  640. int
  641. is_orc(ptr) struct permonst *ptr; {
  642.     return((ptr->mflags2 & M2_ORC) != 0L);
  643. }
  644.  
  645. int
  646. is_human(ptr) struct permonst *ptr; {
  647.     return((ptr->mflags2 & M2_HUMAN) != 0L);
  648. }
  649.  
  650. int
  651. is_demon(ptr) struct permonst *ptr; {
  652.     return((ptr->mflags2 & M2_DEMON) != 0L);
  653. }
  654.  
  655. int
  656. is_mercenary(ptr) struct permonst *ptr; {
  657.     return((ptr->mflags2 & M2_MERC) != 0L);
  658. }
  659.  
  660. int
  661. is_wanderer(ptr) struct permonst *ptr; {
  662.     return((ptr->mflags2 & M2_WANDER) != 0L);
  663. }
  664.  
  665. int
  666. always_hostile(ptr) struct permonst *ptr; {
  667.     return((ptr->mflags2 & M2_HOSTILE) != 0L);
  668. }
  669.  
  670. int
  671. always_peaceful(ptr) struct permonst *ptr; {
  672.     return((ptr->mflags2 & M2_PEACEFUL) != 0L);
  673. }
  674.  
  675. int
  676. extra_nasty(ptr) struct permonst *ptr; {
  677.     return((ptr->mflags2 & M2_NASTY) != 0L);
  678. }
  679.  
  680. int
  681. strongmonst(ptr) struct permonst *ptr; {
  682.     return((ptr->mflags2 & M2_STRONG) != 0L);
  683. }
  684.  
  685. # ifdef POLYSELF
  686. int
  687. can_breathe(ptr) struct permonst *ptr; {
  688.     return(attacktype(ptr, AT_BREA));
  689. }
  690.  
  691. int
  692. cantwield(ptr) struct permonst *ptr; {
  693.     return(nohands(ptr) || verysmall(ptr));
  694. }
  695.  
  696. int
  697. cantweararm(ptr) struct permonst *ptr; {
  698.     return(breakarm(ptr) || sliparm(ptr));
  699. }
  700. # endif /* POLYSELF */
  701.  
  702. int
  703. carnivorous(ptr) struct permonst *ptr; {
  704.     return((ptr->mflags2 & M2_CARNIVORE) != 0L);
  705. }
  706.  
  707. int
  708. herbivorous(ptr) struct permonst *ptr; {
  709.     return((ptr->mflags2 & M2_HERBIVORE) != 0L);
  710. }
  711.  
  712. int
  713. metallivorous(ptr) struct permonst *ptr; {
  714.     return((ptr->mflags2 & M2_METALLIVORE) != 0L);
  715. }
  716.  
  717. int
  718. lays_eggs(ptr) struct permonst *ptr; {
  719.     return((ptr->mflags2 & M2_EGGS) != 0L);
  720. }
  721.  
  722. int
  723. throws_rocks(ptr) struct permonst *ptr; {
  724.     return((ptr->mflags2 & M2_ROCKTHROW) != 0L);
  725. }
  726.  
  727. int
  728. type_is_pname(ptr) struct permonst *ptr; {
  729.     return((ptr->mflags2 & M2_PNAME) != 0L);
  730. }
  731.  
  732. int
  733. is_lord(ptr) struct permonst *ptr; {
  734.     return((ptr->mflags2 & M2_LORD) != 0L);
  735. }
  736.  
  737. int
  738. is_prince(ptr) struct permonst *ptr; {
  739.     return((ptr->mflags2 & M2_PRINCE) != 0L);
  740. }
  741.  
  742. # ifdef INFERNO
  743. int
  744. is_ndemon(ptr) struct permonst *ptr; {
  745.     return(is_demon(ptr) &&
  746.         (ptr->mflags2 & (M2_LORD | M2_PRINCE)) == 0L);
  747. }
  748. # else
  749. int
  750. is_ndemon(ptr) struct permonst *ptr; {
  751.     return(ptr == &mons[PM_DEMON]);
  752. }
  753. # endif
  754.  
  755. int
  756. is_dlord(ptr) struct permonst *ptr; {
  757.     return(is_demon(ptr) && is_lord(ptr));
  758. }
  759.  
  760. int
  761. is_dprince(ptr) struct permonst *ptr; {
  762.     return(is_demon(ptr) && is_prince(ptr));
  763. }
  764.  
  765. #endif /* STUPID_CPP */
  766.  
  767. #endif /* OVLB */
  768.